﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Wechat.API.Filter;
using Wechat.Dto.Request;
using Wechat.Manager;
using Wechat.Util.ReturnMessage;
using Wechat.Util.StateCode;

namespace Wechat.API.Controllers
{
    [RoutePrefix("api/reply"), UnUserAuthorize]
    public class AutoReplyController : ApiController
    {
        public IWechatAutoReplyManager WechatAutoReplyManager { get; set; }

        #region 添加或修改微信关注时默认回复

        /// <summary>
        /// 添加或修改微信关注时默认回复
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [Route("insertorupdate"), HttpPost]
        public ResultMessage InsertOrUpdateAutoReply(WechatAutoReplyRequest request)
        {
            ResultMessage returnMsg = new ResultMessage()
            {
                Status = false
            };
            if (ModelState.IsValid && request != null)
            {
                returnMsg = WechatAutoReplyManager.InsertOrUpdateAutoReply(request);
            }
            else
            {
                returnMsg.Code = (int)EnumApiStateCode.ParameterValidationFailed;
                returnMsg.Message = "参数校验失败";
            }
            return returnMsg;
        }
        #endregion

        #region 获取微信图文信息

        /// <summary>
        /// 获取微信关注时默认回复列表
        /// </summary>
        /// <param name="Search"></param>
        /// <returns></returns>
        [Route("get"), HttpPost]
        public ResultMessage GetAutoReply()
        {
            ResultMessage returnMsg = new ResultMessage()
            {
                Status = false
            };
            if (ModelState.IsValid)
            {
                returnMsg = WechatAutoReplyManager.GetWechatAutoReplyModel();
            }
            else
            {
                returnMsg.Code = (int)EnumApiStateCode.ParameterValidationFailed;
                returnMsg.Message = "参数校验失败";
            }
            return returnMsg;
        }
        #endregion
        
    }
}
